import service from '@/utils/request'

// 房产列表
export function getPropertyList(params) {
  return service({
    url: '/properties',
    params
  })
}

// 新增房产
export function addProperty(data) {
  console.log(data)
  return service({
    method: 'post',
    url: '/properties',
    data
  })
}

// 获取经纪人的列表
export function getAgentList(params) {
  return service({
    url: '/agents',
    params
  })
}
// 获取高德地图地址数据
export function getAddressData() {
  return service({
    method: 'get',
    url: 'https://restapi.amap.com/v3/config/district?parameters',
    params: {
      key: '7c5efe6704eb4579bf5263ab46cedb34',
      subdistrict: 3
    },
    noToken: true
  })
}

// 根据id获取房产详情
export function getPropertyDetail(id) {
  return service({
    url: `/properties/${id}`
  })
}

// 根据id删除房产
export function delProperty(id) {
  return service({
    method: 'delete',
    url: `/properties/${id}`
  })
}

// 修改房产信息
export function editProperty(data) {
  return service({
    method: 'put',
    url: `/properties/${data.id}`,
    data
  })
}

// 获取总数
export function getTotal(params) {
  return service({
    url: '/properties/count',
    params
  })
}

